package com.example.peibei.ui.adapter;

import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.CircleCrop;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.dingtao.common.bean.Order;
import com.dingtao.common.util.GlideUtils;
import com.example.peibei.R;

import java.util.List;

public class MyCollectBillListAdapter extends BaseQuickAdapter<Order.RecordsDTO, BaseViewHolder> {

    public MyCollectBillListAdapter(@Nullable List<Order.RecordsDTO> data) {
        super(R.layout.item_my_bill, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, Order.RecordsDTO item) {
        ImageView head = helper.getView(R.id.iv_head);
        Glide.with(getContext()).load(item.getImgUrl()).apply(RequestOptions.bitmapTransform(new CircleCrop())).into(head);
        helper.setText(R.id.tv_name, item.getNickName()).setText(R.id.tv_address, "来自" + item.getArea()).setText(R.id.tv_dec,item.getContent());
        if (item.getPrice().contains(".")){
            String[] split = item.getPrice().split("\\.");
            helper.setText(R.id.tv_price,split[0]);
        }else{
            helper.setText(R.id.tv_price,item.getPrice());
        }
        LinearLayout llImgs = helper.getView(R.id.ll_imgs);
        RelativeLayout rl_edit = helper.getView(R.id.rl_edit);
        TextView tv_address = helper.getView(R.id.tv_address);
        llImgs.setVisibility(View.GONE);
        rl_edit.setVisibility(View.GONE);
        tv_address.setVisibility(View.GONE);
    }
}
